package com.yzd.otherlearn.jvm;

import com.yzd.otherlearn.util.Print;

public class JConsoleTest3 {
	static class SynAddRunable implements Runnable{
		int a;
		int b ;
		public SynAddRunable(int a , int b) {
			this.a = a ;
			this.b = b ;
		}
		
		public void run() {
			synchronized (Integer.valueOf(a)) {
				synchronized (Integer.valueOf(b)) {
					Print.print(a + b);
				}
			}
		}
	}
	
	public static void main(String[] args) {
		for(int i = 0; i < 100; i++) {
			new Thread(new SynAddRunable(1, 2)).start();
			new Thread(new SynAddRunable(2, 1)).start();
		}
	}
}
